package com.cee.controller;

import com.cee.common.result.Result;
import com.cee.dto.OneSelectDTO;
import com.cee.model.OneSelect;
import com.cee.service.OneSelectService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/oneSelect")
public class OneSelectController {

    @Autowired
    private OneSelectService oneSelectService;


    @PostMapping("/list")
    public Result getOneSelectList(@RequestBody OneSelectDTO oneSelectDTO){
        PageInfo pageInfo = oneSelectDTO.getPageInfo();
        Page<OneSelect> Page = PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());

        oneSelectService.getOneSelectList(oneSelectDTO);

        return Result.ok(new PageInfo<>(Page));
    }


    @GetMapping("/delete")
    public Result deleteOneSelect(Integer id){

        oneSelectService.deleteOneSelect(id);
        return Result.ok();
    }

}
